#!/usr/bin/env python
# -*- coding:utf8 -*-
# uncompyle6 version 2.15.1
# Python bytecode 2.7 (62211)
# Decompiled from: Python 2.7.10 (default, Jul  1 2017, 13:36:56) 
# [GCC 4.4.6 20110731 (Red Hat 4.4.6-4)]
# Embedded file name: ./esb/settings.py
# Compiled at: 2017-11-16 15:44:28
"""
Tencent is pleased to support the open source community by making 蓝鲸智云(BlueKing) available.
Copyright (C) 2017 THL A29 Limited, a Tencent company. All rights reserved.
Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License.
You may obtain a copy of the License at http://opensource.org/licenses/MIT
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License.

Django settings for esb project.

Generated by 'django-admin startproject' using Django 1.8.11.

For more information on this file, see
https://docs.djangoproject.com/en/1.8/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.8/ref/settings/

Copyright © 2012-2017 Tencent BlueKing. All Rights Reserved. 蓝鲸智云 版权所有
"""
import os, time
from django.conf.global_settings import *
try:
    import pymysql
    pymysql.install_as_MySQLdb()
except:
    pass

BASE_DIR = os.path.dirname(os.path.abspath(__file__))
SECRET_KEY = '@3dqbfh23ihs)*ffdck21g(f)+)95qnj4i3n2m-yhafl#&@#hx'
DEBUG = True
ALLOWED_HOSTS = [
 '*']
INSTALLED_APPS = ('django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes',
                  'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles',
                  'esb', 'esb.bkcore')
MIDDLEWARE_CLASSES = ('django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware',
                      'django.contrib.auth.middleware.AuthenticationMiddleware',
                      'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
                      'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware',
                      'django.middleware.security.SecurityMiddleware', 'esb.middlewares.APICommonMiddleware',
                      'esb.middlewares.DebugHelperMiddleware')
ROOT_URLCONF = 'urls'
WSGI_APPLICATION = 'wsgi.application'
TEMPLATES = [
 {'BACKEND': 'django.template.backends.django.DjangoTemplates',
    'DIRS': [],'APP_DIRS': True,
    'OPTIONS': {'context_processors': [
                                     'django.template.context_processors.debug',
                                     'django.template.context_processors.request',
                                     'django.contrib.auth.context_processors.auth',
                                     'django.core.context_processors.i18n',
                                     'django.contrib.messages.context_processors.messages']
                }
    }]
LANGUAGE_CODE = 'zh-hans'
TIME_ZONE = 'Etc/GMT%+d' % ((time.altzone if time.daylight else time.timezone) / 3600)
USE_I18N = True
USE_L10N = True
AUTHENTICATION_BACKENDS = ('django.contrib.auth.backends.ModelBackend', )
PROJECT_PATH = os.path.dirname(os.path.abspath(__file__))
PARENT_DIR = os.path.dirname(os.path.dirname(PROJECT_PATH))
LOG_DIR = os.environ.get('PAAS_LOGGING_DIR') or os.path.join(PARENT_DIR, 'logs')
if not os.path.exists(LOG_DIR):
    os.mkdir(LOG_DIR)
LOG_MAX_BYTES = 104857600
LOG_BACKUP_COUNT = 10
LOG_CLASS = 'logging.handlers.RotatingFileHandler'



def get_loggings(log_level):
    return {'version': 1,
       'disable_existing_loggers': False,
       'formatters': {'verbose': {'format': '%(levelname)s [%(asctime)s] %(pathname)s %(lineno)d %(funcName)s %(process)d %(thread)d %(message)s ',
                                  'datefmt': '%Y-%m-%d %H:%M:%S'
                                  },
                      'simple': {'format': '%(message)s'
                                 },
                      'api_simple': {'format': '%(message)s'
                                     }
                      },
       'handlers': {
           'null': {'level': 'DEBUG',
                             'class': 'logging.StreamHandler'
                             },
                    'console': {'level': 'DEBUG',
                                'class': 'logging.StreamHandler',
                                'formatter': 'simple'
                                },
                    'root': {'class': LOG_CLASS,
                             'formatter': 'verbose',
                             'filename': os.path.join(LOG_DIR, 'esb.log'),
                             'maxBytes': LOG_MAX_BYTES,
                             'backupCount': LOG_BACKUP_COUNT
                             },
                    'api': {'class': LOG_CLASS,
                            'formatter': 'api_simple',
                            'filename': os.path.join(LOG_DIR, 'esb_api.log'),
                            'maxBytes': LOG_MAX_BYTES,
                            'backupCount': LOG_BACKUP_COUNT
                            }
                    },
       'loggers': {'django': {'handlers': [
                                         'null'],
                              'level': 'INFO',
                              'propagate': True
                              },
                   'django.request': {'handlers': [
                                                 'root'],
                                      'level': 'ERROR',
                                      'propagate': True
                                      },
                   'root': {'handlers': [
                                       'root'],
                            'level': log_level,
                            'propagate': False
                            },
                   'api': {'handlers': [
                                      'api'],
                           'level': log_level,
                           'propagate': False
                           },
                   'esb.management': {'handlers': [
                                                 'console'],
                                      'level': 'INFO',
                                      'propagate': False
                                      }
                   }
       }


SITE_URL = '/'
STATIC_URL = SITE_URL + 'static/'
STATIC_VERSION = '0.0.1'
ESB_SITE_ESB_CONF = 'components.esb_conf.config'
JOB_SSL = True
DEFAULT_SSL_ROOT_DIR = '/data/paas/ssl_dir'
from configs.default import *
LOGGING = get_loggings(LOG_LEVEL)
REDIS_CONF_FOR_RATELIMIT = {}
REQUEST_TIMEOUT_SECS = 30
RATE_LIMIT_KEY_NAMESPACE = 'bk_esb_rate_limit'
DJ_POOL_OPTIONS = {'pool_size': 20,
   'max_overflow': 100,
   'recycle': 600
   }
